/*! \file PrimitiveBuilder.cpp
 *	\brief 
 *
 *	created:	2010/07/12
 *	created:	12:7:2010   14:04
 *	filename: 	C:\src\tactics-engine\libs\gd_dx11\PrimitiveBuilder.cpp
 *	file path:	C:\src\tactics-engine\libs\gd_dx11
 *	file base:	PrimitiveBuilder
 *	file ext:	cpp
 *	author:		Vitalii Trubchaninov
 *				venngraydog@gmail.com
 */

#include "gd_dx11/stdafx.h"
#include "gd_dx11/PrimitiveBuilder.h"

#include <gd/IndexBuffer.h>
#include <gd/VertexBuffer.h>

#include "gd_dx11/Device.h"
#include "gd_dx11/IndexBufferImpl.h"
#include "gd_dx11/Primitive.h"
#include "gd_dx11/VertexBufferImpl.h"

namespace tt{
namespace gd_dx11{

PrimitiveBuilder::PrimitiveBuilder( Device* device )
: m_device( device)
{

}

PrimitiveBuilder::~PrimitiveBuilder()
{

}

//////////////////////////////////////////////////////////////////////////
SharedPtr<gd::Primitive> PrimitiveBuilder::onCreatePrimitive()
{
	SharedPtr<gd::Primitive> primitive(new Primitive);
	return primitive;
}

SharedPtr<gd::IndexBuffer> PrimitiveBuilder::onCreateIndexBuffer(UInt count)
{
	ScopedPtr<gd::BufferImpl> bufferImpl(new IndexBufferImpl);
	IndexBufferImpl* indexBufferImpl = static_cast<IndexBufferImpl*>(bufferImpl.get());
	indexBufferImpl->Create(m_device, count);

	SharedPtr<gd::IndexBuffer> indexBuffer( new gd::IndexBuffer(bufferImpl) );
	return indexBuffer;
}

SharedPtr<gd::VertexBuffer> PrimitiveBuilder::onCreateVertexBuffer(const gd::VertexFormat& format, UInt count)
{
	ScopedPtr<gd::BufferImpl> bufferImpl(new VertexBufferImpl);
	VertexBufferImpl* vertexBufferImpl = static_cast<VertexBufferImpl*>(bufferImpl.get());
	vertexBufferImpl->Create(m_device, format, count);
	
	SharedPtr<gd::VertexBuffer> vertexBuffer(new gd::VertexBuffer(bufferImpl) );
	return vertexBuffer;
}

} //namespace gd_dx11
} //namespace tt

